Don't understand the typing of Scala's delimited continuations (A @cps[B,C])
Posted
by jkff
on Stack Overflow
See other posts from Stack Overflow
or by jkff
Published on 2010-03-13T07:46:28Z
Indexed on
2010/03/13
7:55 UTC
Read the original article
Hit count: 451
I'm struggling to understand what precisely does it mean when a value has type A @cps[B,C]
and what types of this form should I assign to my values when using the delimited continuations facility.
I've looked at some sources:
http://lamp.epfl.ch/~rompf/continuations-icfp09.pdf
http://www.scala-lang.org/node/2096
http://dcsobral.blogspot.com/2009/07/delimited-continuations-explained-in.html
http://blog.richdougherty.com/2009/02/delimited-continuations-in-scala_24.html
but they didn't give me much intuition into this. In the last link, the author tries to give an explicit explanation, but it is not clear enough anyway.
The A here represents the output of the computation, which is also the input to its continuation. The B represents the return type of that continuation, and the C represents its "final" return type—because shift can do further processing to the returned value and change its type.
I don't understand the difference between "output of the computation", "return type of the continuation" and "final return type of the continuation". They sound like synonyms.
© Stack Overflow or respective owner